package server

import (
	"context"
	"gitee.com/kmyss/gf-ex/yslog"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/gogf/gf/v2/os/glog"
)

// region API 定义

// WebSocketReq WebSocket请求体
type WebSocketReq struct {
	g.Meta `path:"/ws" tags:"WebSocket" method:"get" summary:"WebSocket 连接请求"`
}

type WebSocketRes struct{}

// endregion

func webSocket() *cWebSocket {
	return &cWebSocket{}
}

type cWebSocket struct {
	l *glog.Logger
}

func (c *cWebSocket) log() *glog.Logger {
	if c.l == nil {
		c.l = yslog.Log("web-socket")
	}
	return c.l
}

func (c *cWebSocket) WebSocketHandler(ctx context.Context, req *WebSocketReq) (res *WebSocketRes, err error) {

	r := ghttp.RequestFromCtx(ctx)

	r.WebSocket()
	return
}
